<template>
	<view>
		<view class="info" v-show="coupon">
			<view class="flex-row justify-between align-center">
				<view>产品名称</view>
				<view class="black">{{coupon.coupon_name}}</view>
			</view>
			<view class="flex-row justify-between align-center">
				<view>有效期</view>
				<view class="black">{{coupon.expire_time}}</view>
			</view>
			<view class="flex-row justify-between align-center">
				<view>订单信息</view>
				<view class="black">{{coupon.desc}}</view>
			</view>
			<view class="flex-row justify-between align-center">
				<view>价格</view>
				<input class="active" v-model="sell_price" type="number" placeholder="请输入价格" style="text-align: right;">
			</view>
		</view>

		<my-btn gold style="margin: 60rpx auto" @click="sell">立即出售</my-btn>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				coupon: '',
				sell_price: ''
			};
		},
		onLoad(opt) {
			this.id = opt.id
			this.getData()
		},
		methods: {
			getData() {
				this.$u.get('/coupons/info?coupon_sn=' + this.id).then(res => {
					this.coupon = res.data.result.coupon
				})
			},
			sell() {
				let params = {
					coupon_sn: this.id,
					sell_price: this.sell_price
				}
				this.$u.post('/coupons/sale', params).then(res => {
					this.$msg(res.data.msg, 1000, true).then(res => this.$goto(1))
				})
			}
		}
	}
</script>

<style lang="scss">
	.info {
		padding: 36rpx;
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		background: #fff;

		.active {
			color: #FF8B56;
		}

		.black {
			color: black;
		}

		.flex-row {
			height: 80rpx;
			border-bottom: 1rpx solid rgba(0, 0, 0, 0.03);
		}
	}
</style>
